.Dd April 21, 2017
.Dt SPM 1
.Sh NAME
.Nm spm
.Nd simple password manager
.Sh SYNOPSIS
.Nm
.Cm add Oo Ar group/ Oc Ns Ar entry
.Nm
.Cm del Ar expression
.Nm
.Cm help
.Nm
.Cm list Oo Fl g Oc Op Ar group
.Nm
.Cm search Ar expression
.Nm
.Cm show Ar expression
.Sh DESCRIPTION
.Nm
is a fully POSIX shell compliant script using
.Xr gpg2 1
for encryption.
.sp
Entries are stored in a classical filesystem hierarchy where passwords
are encrypted as individual files and directories may be used as groups.
This way users can control access through file ownership, share entries
entries with symbolic links and more just like any other files.
.sp
Group and entry names or expressions are considered relative to the
storage root directoy.
.Ar expression
is interpreted as basic regular expression according to
.Xr re_format 7 .
The following commands are available:
.Bl -tag -width Ds
.It Cm add
Prompt for a password if standard output is a terminal otherwise read
from standard input and store it as
.Ar entry .
If
.Ar group
is specified, non-existing groups are created automatically and the
password is stored under
.Ar group/ Ns Op Ar ../ .
.It Cm del
Ask for confirmation and delete the entry matching
.Ar expression
on success.
.It Cm help
Print a short usage and refer to this manual page.
.It Cm list
Print a recursive, indented tree-style list of all entries in
.Ar group .
If
.Ar group
is omitted, the entire storage root is listed.
If the
.Fl g
flag is passed only subgroups are shown.
.It Cm search
Print the absoloute paths of all entries matching
.Ar expression
one per line.
.It Cm show
Print the password to standard output if
.Ar expression
uniquely matches an entry and prompt for the decryption passphrase if
it is not cached by
.Xr gpg-agent 1
already.
.El
.Sh ENVIRONMENT
The following environment variables will be used by
.Nm
if they are set and not empty:
.Bl -tag -width Ds
.It Ev PASSWORD_STORE_DIR
The storage root directory.
This should be an absoloute path.
.It Ev PASSWORD_STORE_KEY
Key ID used for de/encryption.
Refer to
.Xr gpg2 1
for accepted formats.
.El
.Sh FILES
.Bl -tag -width Ds
.It Pa ~/.spm/
The default storage root directory.
.El
.Sh EXIT STATUS
.Nm
exits 1 if an error occurs otherwise 0.
.Sh EXAMPlES
Add Alice's password to the group
.Em users :
.Bd -literal -offset indent
$ spm add users/alice
Password for 'users/alice':
.Ed
.sp
Make sure she is an admin as well:
.Bd -literal -offset indent
$ (cd ~/.spm
> mkdir admins
> ln -s ../members/alice admins/alice)
.Ed
.sp
Copy her password into the X selection ready to be pasted somewhere:
.Bd -literal -offset indent
$ spm show admins/alice | xclip -i
.Ed
.sp
Find all admins starting with
.Dq a
or
.Dq b :
.Bd -literal -offset indent
$ spm search admins/[ab]
/home/alice/.spm/admins/alice
/home/alice/.spm/admins/bob
.Ed
.sp
List all users:
.Bd -literal -offset indent
$ spm list users
/home/alice/.spm/users
|-- alice
|-- bob
|-- temporary/
|   |-- tim
|   `-- tom
.Ed
.sp
Find entries interactively using
.Xr dmenu 1 :
.Bd -literal -offset indent
$ spm show "$(spm search . | dmenu -l 10)"
.Ed
.Sh SEE ALSO
.Xr dmenu 1,
.Xr gpg2 1 ,
.Xr gpg-agent 1 ,
.Xr tpm 1 ,
.Xr tree 1 ,
.Xr re_format 7
.Sh CAVEATS
Groups have to be deleted manually using
.Xr rmdir 1 .
.Sh AUTHORS
.Nm
is written by
.An Klemens Nanni Aq Mt kl3@posteo.org .
